# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=libimobiledevice-glue
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.1
pkgrel=1
pkgdesc='A library with common code used by libraries and tools around the libimobiledevice project (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.libimobiledevice.org/'
msys2_repository_url="https://github.com/libimobiledevice/libimobiledevice-glue"
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libplist")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=(https://github.com/libimobiledevice/libimobiledevice-glue/releases/download/${pkgver}/${_realname}-${pkgver}.tar.bz2)
sha256sums=('6e2849f221e6ab970566a115d42f3c20f8848e4d40c2ed61ac20dc85f40fa54f')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
}
